local PATH = ...

package.path = string.format("%s/lualib/?.lua;%s/skynet/lualib/?.lua;%s/client/?.lua", PATH, PATH, PATH)
package.cpath = string.format("%s/skynet/luaclib/?.so;%s/luaclib/?.so;", PATH, PATH)

if _VERSION ~= "Lua 5.4" then 
    error "Use lua 5.4"
end

local socket = require "socket"
local message = require "message"
local connect = require "connect"

local handshake_index = 1

local function main()
    message.register_sproto(PATH)

    local ok, resp = pcall(connect.connect_login_server)
    local ok, fd = pcall(connect.connect_gate_server, resp.servername, resp.uid, handshake_index, resp.secret)

    if ok and fd ~= nil then 
        message.set_fd(fd)
    end

    while true do 
        message.dispatch_package(fd)
        local stdin = require "client.socket".readstdin()
        if stdin then 

        end
    end

    socket.close(fd)
end

main()